﻿using Diablo3.Services.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Diablo3.Services.Model.Profiles
{
    [DataContract]
    public class Profile
    {
        #region Properties

        /// <summary>
        /// The heroes
        /// </summary>
        [DataMember(Name = "heroes")]
        private Hero[] _heroes = null;
        /// <summary>
        /// Gets the heroes.
        /// </summary>
        /// <value>
        /// The heroes.
        /// </value>
        public Hero[] Heroes
        {
            get { return this._heroes; }
        }

        /// <summary>
        /// The last hero played
        /// </summary>
        [DataMember(Name = "lastHeroPlayed")]
        private long _lastHeroPlayed = 0;
        /// <summary>
        /// Gets the last hero played.
        /// </summary>
        /// <value>
        /// The last hero played.
        /// </value>
        public Hero LastHeroPlayed
        {
            get
            {
                for (int i = 0; i < this._heroes.Length; i++)
                {
                    if (this._heroes[i].Id == this._lastHeroPlayed)
                    {
                        return this._heroes[i];
                    }
                }

                return null;
            }
        }

        /// <summary>
        /// The last updated
        /// </summary>
        [DataMember(Name = "lastUpdated")]
        private long _lastUpdated = 0;
        /// <summary>
        /// Gets the last updated.
        /// </summary>
        /// <value>
        /// The last updated.
        /// </value>
        public DateTimeOffset LastUpdated
        {
            get { return this._lastUpdated.ToUnixTimestamp(); }
        }

        /// <summary>
        /// The kills
        /// </summary>
        [DataMember(Name = "kills")]
        private Kills _kills = null;
        /// <summary>
        /// Gets the kills.
        /// </summary>
        /// <value>
        /// The kills.
        /// </value>
        public Kills Kills
        {
            get { return this._kills; }
        }

        /// <summary>
        /// The time played
        /// </summary>
        [DataMember(Name = "timePlayed")]
        private TimePlayed _timePlayed = null;
        /// <summary>
        /// Gets the time played.
        /// </summary>
        /// <value>
        /// The time played.
        /// </value>
        public TimePlayed TimePlayed
        {
            get { return this._timePlayed; }
        }

        /// <summary>
        /// The fallen heroes
        /// </summary>
        [DataMember(Name = "fallenHeroes")]
        private FallenHero[] _fallenHeroes = null;
        /// <summary>
        /// Gets the fallen heroes.
        /// </summary>
        /// <value>
        /// The fallen heroes.
        /// </value>
        public FallenHero[] FallenHeroes
        {
            get { return this._fallenHeroes; }
        }

        /// <summary>
        /// The battle tag
        /// </summary>
        [DataMember(Name = "battleTag")]
        private string _battleTag = null;
        /// <summary>
        /// Gets the battle tag.
        /// </summary>
        /// <value>
        /// The battle tag.
        /// </value>
        public string BattleTag
        {
            get { return this._battleTag; }
        }

        #endregion
    }
}
